package View.GeneralManagerView.VariablePanel;

public class DecoratedVariablePane extends VariablePane{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String defaultValue[];
	
	
	public void setDefaultContain(String[] s){
		if(s.length!=this.contains.size)
			return;
		
		for(int i=0;i<s.length;i++){
			defaultValue[i] = s[i];
		}
		setContain(s);
	}
	
	public void setContain(String[] s){
		if(s.length!=this.contains.size)
			return;
		
		InputField t[] = super.contains.inputBox;
		for(int i=0;i<s.length;i++){
			((InputFieldWithDefaultValue)t[i]).setDefaultValue(s[i]);
		}
		
	}
	
	public void recruit(){
		InputField t[] = super.contains.inputBox;
		for(int j=0;j<t.length;j++){
			((InputFieldWithDefaultValue)t[j]).setDefaultValue(defaultValue[j]);
		}
	}
	
	public DecoratedVariablePane(int width,int height,String...args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
		super(width,height);
		String tmp[] = new String[args.length*2/3];
		defaultValue = new String[args.length/3+1];
		int l=0,k=0;
		for(int i=0;i<args.length;i++){
			if(i%3==0){
				tmp[l] = args[i];
				l++;
			}else if(i%3==1){
				tmp[l] = args[i];
				l++;
			}else{
				defaultValue[k] = args[i];
				k++;
			}
		}

			super.addItems(tmp);
		
		InputField t[] = super.contains.inputBox;
		for(int j=0;j<t.length;j++){
			((InputFieldWithDefaultValue)t[j]).setDefaultValue(defaultValue[j]);
		}
	}
	
}